import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/index-layout'
import Login from '@/views/login/index-login'
import Home from '@/views/home/home'

const Product = () => import('@/views/product/index')
const List = () => import('@/views/product/list/index')
const Category = () => import('@/views/product/category/index')
const AddProduct = () => import('@/views/product/list/AddProduct.vue')

const Order = () => import('@/views/order/index')
const OrderList = () => import('@/views/order/list/index')
const Collect = () => import('@/views/order/collect/index')
const Contract=()=>import('@/views/order/contract/index')

const Advert = () => import('@/views/advert/index')
const AdvertList = () => import('@/views/advert/list/index')

//系统管理
import SystemManage from '@/views/SystemManage'
import department from '@/views/SystemManage/department'
import role from '@/views/SystemManage/role'


Vue.use(VueRouter)

const routes = [
  {
    path: '',
    name: 'index-test',
    component: Layout,
    meta:{
      title:'首页1',
      isLogin:true
    },
    children: [
      {
        path: '/',
        name: 'home',
        component: Home,
        meta:{
          title:'首页2'
        },
      },
      {
        path: '/product',
        name: 'product',
        component: Product,
        meta:{
          title:'产品管理'
        },
        redirect:'/product/list',
        children: [
          {
            path: 'list',// 路径/product/list
            name: 'plist',
            component: List,
            meta:{
              title:'产品列表'
            },
          },
          {
            path: 'category',// 路径 /product/category
            name: 'category',
            component: Category,
            meta:{
              title:'产品分类'
            },
          },
          {
            path: 'add-product',// 商品添加，编辑，查看
            name: 'AddProduct',
            component: AddProduct,
            meta: {//配置高亮标识
              activeMenu: '/product/list',
              title:'商品详情'
            }
          },
        ]
      },

      {
        path: '/order',
        name: 'order',
        component: Order,
        meta:{
          title:'订单管理'
        },
        redirect:'/order/list',
        children: [
          {
            path: 'list',// 路径/order/list
            name: 'olist',
            component: OrderList,
            meta:{
              title:'订单列表'
            },
          },
          {
            path: 'collect',// 路径 /order/collect
            name: 'collect',
            component: Collect,
            meta:{
              title:'订单汇总'
            },
          },
          {
            path: 'contract',// 路径 /order/contract
            name: 'contract',
            component: Contract,
            meta:{
              title:'订单打印'
            },
          },
        ]
      },

      {
        path: '/advert',
        name: 'advert',
        component: Advert,
        meta:{
          title:'广告管理'
        },
        
        children: [
          {
            path: 'list',// 路径/advert/list
            name: 'alist',
            component: AdvertList,
            meta:{
              title:'广告列表'
            },
          }
        ]
      },
      {
        path: "/system",
        name: "system",
        component: SystemManage,
        redirect: "/system/role",
        meta: {
          title: "系统管理",
        },
        children: [
          {
            path: "role",
            name: "role",
            component: role,
            meta: {
              title: "角色管理",
            },
          },
          {
            path: "department",
            name: "department",
            component: department,
            meta: {
              title: "部门管理",
            },
          },
        ],
      },

    ]



  },
  {
    path: '/login',
    name: 'login-test',
    component: Login
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})



export default router
